#!/bin/sh
set -eu

# Build DocBook document using latest (draft) translations

# PO files are saved to a directory outside the locale dirs
# to avoid overwriting versioned files.

draft_dir=target/draft
mkdir -p $draft_dir

echo "Pulling latest translations from Zanata server"
# write PO files to a different directory under target
mvn zanata:pull -e -Dzanata.transDir=$draft_dir

# draft build the translated documents
# (alternative: run Ant from weld/build/dist)

# copy en-US source to draft dir for use by jDocBook
cp -a ./en-US $draft_dir/en-US

echo "Building translated documentation with jDocBook"

# pick up PO files from the different directory above
mvn compile -Ptranslations -DjdocbookSourceDirectory=$draft_dir

echo "Finished! You may need to overwrite pot and locale dirs from version control"
